<template>
  <div>
    <div ref="editor">
    </div>
  </div>
</template>

<script>
import E from 'wangeditor'
export default {
  name: 'editor',
  data () {
    return {
      editor: null,
    }
  },
  props: {
    value: {
      default: ""
    }
  },
  mounted() {
    this.editor = new E(this.$refs.editor)
    this.editor.config.onchange = (html) => {
      this.$emit("input", html);
    }
    this.editor.create();
    this.editor.txt.html(this.value);
    this.$watch('value', () => {
      this.editor.txt.html(this.value)
    })
  }
}
</script>

<style>

</style>
